package com.yang.spring.core.bean.enums;

import com.yang.spring.core.annotations.Bean;
import com.yang.spring.core.annotations.Component;
import com.yang.spring.core.annotations.Configuration;
import com.yang.spring.core.annotations.Service;

public enum BeanTypeEnum {
    COMPONENT(Component.class),
    SERVICE(Service.class),
    CONFIGURATION(Configuration.class),
    BEAN(Bean.class);

    private Class clazz;

    BeanTypeEnum(Class clazz) {
        this.clazz = clazz;
    }

    public Class getClazz() {
        return clazz;
    }

    public static BeanTypeEnum getBeanTypeByClazz(Class clazz) {
        for (BeanTypeEnum beanType : values()) {
            if (clazz.isAnnotationPresent(beanType.getClazz())) {
                return beanType;
            }
        }
        return null;
    }
}
